package com.beerq.view.me;

import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.webkit.WebView;
import android.widget.LinearLayout;

import com.beerq.R;
import com.beerq.util.ViewPaperUtil;
import com.beerq.util.WebViewUtil;
import com.beerq.view.BaseActivity;

import java.util.ArrayList;
import java.util.List;

public class MyOrderActivity extends BaseActivity  implements View.OnClickListener {


    private ViewPager mViewPager;
    private List<View> mListViews;



    private LinearLayout mLinAll;
    private LinearLayout mLinWaittingPay;
    private LinearLayout mLinWaittingGo;
    private LinearLayout mLinWaittingReceiver;
    private LinearLayout mLinWaittingEvaluate;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        statusBarType=1;
        super.onCreate(savedInstanceState);
        setMainContentView(R.layout.activity_my_order);
        setBarTitle("我的订单");
        initView();
    }




    private void initView(){

        mLinAll = (LinearLayout) findViewById(R.id.lin_all);
        mLinWaittingPay = (LinearLayout)findViewById(R.id.lin_watting_pay);
        mLinWaittingGo = (LinearLayout) findViewById(R.id.lin_watting_go);
        mLinWaittingReceiver = (LinearLayout) findViewById(R.id.lin_watting_receiver);
        mLinWaittingEvaluate = (LinearLayout) findViewById(R.id.lin_watting_evaluate);

        mLinAll.setOnClickListener(this);
        mLinWaittingPay.setOnClickListener(this);
        mLinWaittingGo.setOnClickListener(this);
        mLinWaittingReceiver.setOnClickListener(this);
        mLinWaittingEvaluate.setOnClickListener(this);


        mViewPager = (ViewPager)findViewById(R.id.id_viewpager);

        mListViews = new ArrayList<View>();
        addView(mListViews,"");
        addView(mListViews, "");

        addView(mListViews, "");
        addView(mListViews, "");
        addView(mListViews, "");

        new ViewPaperUtil(this,mViewPager).bind(mListViews,null);


    }

    private void addView(List<View> viewList, String url) {
        WebView webView = new WebView(this);

        WebViewUtil.initWebView(this,webView);
        webView.loadUrl(url);
        viewList.add(webView);
    }


    @Override
    public void onClick(View v) {
        int vId = v.getId();

        switch (vId) {
            case R.id.lin_all:
                mViewPager.setCurrentItem(0);
                break;
            case R.id.lin_watting_pay:
                mViewPager.setCurrentItem(1);
                break;
            case R.id.lin_watting_go:
                mViewPager.setCurrentItem(2);
                break;
            case R.id.lin_watting_receiver:
                mViewPager.setCurrentItem(3);
                break;
            case R.id.lin_watting_evaluate:
                mViewPager.setCurrentItem(4);
                break;
        }
    }


}
